package com.example.zhinongbao.presenter;

import com.example.zhinongbao.contract.HomeContract;
import com.example.zhinongbao.model.HomeModel;
import com.example.zhinongbao.model.Product;
import java.util.List;

public class HomePresenter implements HomeContract.Presenter {
    private HomeContract.View view;
    private HomeContract.Model model;

    public HomePresenter(HomeContract.View view) {
        this.view = view;
        this.model = new HomeModel();
    }

    @Override
    public void loadProducts() {
        List<Product> products = model.getAllProducts();
        view.showProducts(products);
    }

    @Override
    public void searchProducts(String query) {
        List<Product> results = model.searchProducts(query);
        view.showSearchResults(results);
    }
}